<?php
class FileCommon {
	/**
	 * @author Corey <corey.erp@gmail.com> 2012-12-09
	 * 统计目录下的总文件数.
	 */
	function readGiveDir($dir, $fileExt) {
		$filenum = 0;
		if ($dh = opendir($dir)) {
			while (($file = readdir($dh)) !== false) {
				if (in_array($file, array(".", "..", '.svn'))) continue;
				if (is_dir($dir . '/' . $file)) {
					list($num) = common('File')->readGiveDir($dir . '/' . $file, $fileExt);
					$filenum += $num;
				} else {
					if (strrchr($file, '.') == $fileExt) {
						$filenum ++;
						continue;
					}
				}
			}
			closedir($dh);
		} else {
			echo 'open dir <' . $dir . '> error!' . "\r";
		}
		return array($filenum);
	}
}
?>